package com.sofwin.ruoyi.scyffinal.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author liuxingchen
 * @packageName com.sofwin.ruoyi.scyffinal.enums
 * @project javaruoyi
 * @date 2025/10/15
 * @description:...
 */
public enum RiskLevelEnum implements BaseEnum{
    PRIMARY(1, "低风险"),
    INTERMEDIATE(2, "一般风险"),
    ADVANCED(3, "较大风险")
    ;

    /**
     * 数据库中储存的数值
     * @return
     */
    @EnumValue
    private Integer riskLevel;

    /**
     * 对应的页面显示的文字
     * @return
     */
    @JsonValue
    private String riskLevelName;

    //风险等级
    RiskLevelEnum(Integer riskLevel, String riskLevelName) {
        this.riskLevel = riskLevel;
        this.riskLevelName = riskLevelName;
    }


    @Override
    public Integer getRiskLevel() {
        return riskLevel;
    }
    @Override
    public String getRiskLevelName() {
        return riskLevelName;
    }

    /**
     * 根据riskLevel获取枚举
     */
    public static RiskLevelEnum getByRiskLevel(Integer riskLevel) {
        if (riskLevel == null) {
            return null;
        }
        // 遍历枚举
        for (RiskLevelEnum value : values()) {
            if (value.getRiskLevel().equals(riskLevel)) {
                return value;
            }
        }
        return null;
    }
}
